package com.doform.android.xianggucheng.help;

import android.content.Context;

import com.doform.android.xianggucheng.utils.Constans;
import com.doform.android.xianggucheng.utils.SP;

/**
 * 作者 Y_MS
 * Created by ${APEN} on 2017/5/27.
 * GitHub：https://github.com/cxydxpx
 */

public class AppHelp {

    private static AppHelp instance;
    /**
     * 多方金福
     */
    private String moneyCurrency;
    /**
     * 基金
     */
    private String moneyFundCode;
    /**
     * 商户号
     */
    private String moneyMerchantid;

    /**
     * 开启测试服务器
     */
    public final Boolean Debug = false;
    private int isFinancial;

    public static synchronized AppHelp getInstance() {
        if (instance == null) {
            instance = new AppHelp();
        }
        return instance;
    }

    private Context mContext;

    public void init(Context context) {
        this.mContext = context;
    }

    public void setUserName(String userName) {
        SP.put(mContext, "username", userName);
    }

    public String getUserName() {
        return (String) SP.get(mContext, "username", null);
    }

    public void setPassrod(String passWrod) {
        SP.put(mContext, "passwrod", passWrod);
    }

    public String getPassword() {
        return (String) SP.get(mContext, "passwrod", "");
    }

    /**
     * 用户权限1:老板2:小工3:销售
     *
     * @param type
     */
    public void setUserType(int type) {
        SP.put(mContext, "usertype", type);
    }

    public int getUserType() {
        return (int) SP.get(mContext, "usertype", 0);
    }

    public String getToken() {
        return (String) SP.get(mContext, "userToken", "");
    }

    public void setToken(String token) {
        SP.put(mContext, "userToken", token);
    }


    public void setMoneyCurrency(String moneyCurrency) {
        this.moneyCurrency = moneyCurrency;
    }

    public void setMoneyFundCode(String moneyFundCode) {
        this.moneyFundCode = moneyFundCode;
    }

    public void setMoneyMerchantid(String moneyMerchantid) {
        this.moneyMerchantid = moneyMerchantid;
    }

    public String getMoneyCurrency() {
        return moneyCurrency;
    }

    public String getMoneyFundCode() {
        return moneyFundCode;
    }

    public String getMoneyMerchantid() {
        return moneyMerchantid;
    }

    public void setUrl(String apiurl) {
        SP.put(mContext, "url", apiurl);
    }

    public String getUrl(){
        return (String) SP.get(mContext, "url", Constans.FORMAL_URL);
    }

    public void setIsFinancial(int isFinancial) {
        SP.put(mContext, "isFinancial", isFinancial);
    }

    public int getIsFinancial(){
        return (int) SP.get(mContext, "isFinancial",0);
    }
}
